package datasv.framework_datasv;

import po.SubModelPO;
import resultmessage.FrameworkRM;

public class UpdateSubModel {
	public static void main(String[] args) {
		String category="1234425";
		String name="sub3";
		int hS=2;
		int tS=5;
		int headCredit=1;
		int tailCredit=8;
		System.out.println(new UpdateSubModel().updateSubModel("001", "00101", new SubModelPO("001010202", category, name, hS, tS, headCredit, tailCredit)));
	}
	public FrameworkRM updateSubModel(String collegeID, String modelID, SubModelPO po){
		return updateInSql(collegeID, modelID, po);
	}
	private FrameworkRM updateInSql(String collegeID, String modelID, SubModelPO po){
		modelID=po.getSubModelID().substring(0,7);
		FrameworkRM rm=new DeleteSubModel().deleteSubModel(collegeID,modelID, po.getSubModelID());
		if(!rm.equals(FrameworkRM.SUCCESS)){
			return rm;
		}
		rm=new AddSubModel().addSubModel(collegeID,modelID, po);
		if(!rm.equals(FrameworkRM.SUCCESS)){
			return rm;
		}
		return FrameworkRM.SUCCESS;	
	}
}